package com.yequan.hbb.model;

import com.yequan.hbb.entries.AnswerEntries;
import com.yequan.hbb.servers.Servers;
import com.yequan.hbb.utils.ServerUtil;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * Created by DingLong on 2016/10/14.
 */

public class AnswerModel extends MVPModel{
    private AnswerCallBack answerCallBack;

    public AnswerModel(AnswerCallBack answerCallBack) {
        this.answerCallBack = answerCallBack;
    }

    public void getData(int contentId) {
        Call<AnswerEntries> call = ServerUtil.createHttpRequest(Servers.class).getAnswerInfo(contentId);
        call.enqueue(new Callback<AnswerEntries>() {
            @Override
            public void onResponse(Call<AnswerEntries> call, Response<AnswerEntries> response) {
                answerCallBack.onResponse(call,response);
            }

            @Override
            public void onFailure(Call<AnswerEntries> call, Throwable t) {
                answerCallBack.onFailure(call,t);
            }
        });
    }

    public interface AnswerCallBack {
        void onResponse(Call<AnswerEntries> call, Response<AnswerEntries> response);

        void onFailure(Call<AnswerEntries> call, Throwable t);
    }
}

